const fontSize = (res) => {
	let docEl = document.documentElement,
		clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
	if (!clientWidth) return;
	let fontSize = 100 * (clientWidth / 1920);
	return res * fontSize;
}


// 千分位逗号隔开（,）
const formatNumberRgx = (num) => {
	var parts = num.toString().split(".");
	parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
	return parts.join(".");
}
// 获取当前日期 
const formatDate = () => {
	let date = new Date();
	let year = date.getFullYear(); // 年
	let month = date.getMonth() + 1; // 月

	month = month < 10 ? "0" + month : month; // 如果只有一位，则前面补零
	let day = date.getDate(); // 日
	day = day < 10 ? "0" + day : day; // 如果只有一位，则前面补零
	// return `${year}${month}${day}`;
	// var datastr = year + "-" + month + "-" + day;
	var datastr =[ year,month,day]
	return datastr;
}

//获取当前时间后一天
const getTomorrowDate = (Y, M, D)=>{
            var nowdate = new Date();
            nowdate.setDate(nowdate.getDate() + 1);
            var year = nowdate.getFullYear();
            var month = nowdate.getMonth() + 1 < 10 ? "0" + (nowdate.getMonth() + 1) : nowdate.getMonth() + 1;
            var day = nowdate.getDate() < 10 ? "0" + nowdate.getDate() : nowdate.getDate();
            // var formatwdate = y + '-' + m + '-' + d;
           // var datastr = year + "-" + month + "-" + day;
		   var datastr =[ year,month,day]
           return datastr;
        }
		//获取当前时间下一个月
const getNextMonth = () => {
	let date = new Date();
	let year = date.getFullYear(); // 年
	let month = date.getMonth() + 1; // 月
	month = month < 10 ? "0" + month : month; // 如果只有一位，则前面补零
	let day = date.getDate(); // 日
	day = day < 10 ? "0" + day : day; // 如果只有一位，则前面补零
	var days = new Date(year, month, 0);
	days = days.getDate(); //获取当前日期中的月的天数
	var year2 = year;
	var month2 = parseInt(month) + 1;
	if (month2 == 13) {
		year2 = parseInt(year2) + 1;
		month2 = 1;
	}
	var day2 = day;
	var days2 = new Date(year2, month2, 0);
	days2 = days2.getDate();
	if (day2 > days2) {
		day2 = days2;
	}
	if (month2 < 10) {
		month2 = '0' + month2;
	}
	// var datastr = year2 + "-" + month2 + "-" + day2;
	var datastr =[ year2,month2,day2]
	return datastr;
}
// 当前日期的前一个月
const getPreMonth = (Y, M, D) => {
	let date = new Date();
	let year = date.getFullYear(); // 年
	let month = date.getMonth() + 1; // 月
	month = month < 10 ? "0" + month : month; // 如果只有一位，则前面补零
	let day = date.getDate(); // 日
	day = day < 10 ? "0" + day : day; // 如果只有一位，则前面补零  
	var days = new Date(year, month, 0);
	days = days.getDate(); //获取当前日期中月的天数  
	var year2 = year;
	var month2 = parseInt(month) - 1;
	if (month2 == 0) {
		year2 = parseInt(year2) - 1;
		month2 = 12;
	}
	var day2 = day;
	var days2 = new Date(year2, month2, 0);
	days2 = days2.getDate();
	if (day2 > days2) {
		day2 = days2;
	}
	if (month2 < 10) {
		month2 = '0' + month2;
	}

	// var datastr = year2 + "-" + month2 + "-" + day2;
	var datastr =[ year2,month2,day2]
	return datastr;
	
}
// 获取当前日期的前一年的年月日
const getLastYearYestdy = () => {
	// let date = new Date(this.getPreMonth(Y, M, D));
	// console.log(date)
	let date = new Date();
	// let date =  
	var strYear = date.getFullYear() - 1;
	var strMonth = date.getMonth() + 1;
	var strDay = date.getDate();

	if (strMonth < 10) {
		strMonth = "0" + strMonth;
	}
	if (strDay < 10) {
		strDay = "0" + strDay;
	}
	// var datastr = strYear + "-" + strMonth + "-" + strDay;
	var datastr =[ strYear,strMonth,strDay]
	return datastr;
}
export default {
	fontSize,
	formatNumberRgx,
	//当前日期 日 月 年
	formatDate,
	//当前日期的后一天 （明天）
	getTomorrowDate,
	//当前日期的下一个月 
	getNextMonth,
	//当前日期的前一个月 
	getPreMonth,
	//当前日期的前一年
	getLastYearYestdy
}
